# -*- coding: utf-8 -*-
# @Author : HaleShi
# @Time : 2023-07-06
# @File : 0_hook_g.py

import frida
import sys

rdev = frida.get_remote_device()
pid = rdev.spawn("com.dashang.tiangou")
session = rdev.attach(pid)

scr = """
function hook_RegisterNatives() {
    Java.perform(function () {
        var d0 = Java.use("com.dashang.tiangou.http.d0");
        d0.g.implementation = function (context,requestParams,aVar) {
            console.log("---------------------")
            console.log("这是参数context:",context);
            console.log("这是参数requestParams:",requestParams);
            console.log("这是参数aVar:",aVar);
            var res = this.g(context,requestParams,aVar);
            console.log(res);
            return res;
        };
    });
}

setImmediate(hook_RegisterNatives);
"""
script = session.create_script(scr)


def on_message(message, data):
    print(message, data)


script.on("message", on_message)

script.load()
rdev.resume(pid)
sys.stdin.read()
